﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;

namespace MWTools.Client.Common
{
    public class Utilities
    {

        public static ulong UserId
        {
            get
            {
                return 421;
            }
        }

        public static byte[] GetSimpleHash(string data)
        {
            byte[] tmpSource;
            byte[] tmpHash;

            tmpSource = ASCIIEncoding.ASCII.GetBytes(data);
            tmpHash = new MD5CryptoServiceProvider().ComputeHash(tmpSource);

            return tmpHash;
        }


        /// <summary>
        /// Computes a hash value for password functions
        /// </summary>
        /// <param name="value">Value To Hash</param>
        /// <returns></returns>
        public static string GetSha1(string value)
        {
            var data = Encoding.ASCII.GetBytes(value);
            var hashData = new SHA1Managed().ComputeHash(data);

            var hash = string.Empty;

            foreach (var b in hashData)
                hash += b.ToString("X2");

            return hash;
        }
    }
}
